﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogoUI.ViewModels
{
    internal static class Extensions
    {
        /// <summary>
        ///  Performs the specified action on each element of the <see cref="IEnumerable{T}"/> 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ie"></param>
        /// <param name="action">The <see cref="System.Action(T)"/> delegate to perform on each element of the <see cref="IEnumerable{T}"/>.</param>
        /// <exception cref="System.ArgumentNullException">action is null.</exception>
        public static void Apply<T>(this IEnumerable<T> ie, Action<T> action)
        {
            foreach (T e in ie)
            {
                action(e);
            }
        }

        /// <summary>
        /// IEnumerable implementation of Apply
        /// </summary>
        /// <param name="ie"></param>
        /// <param name="action"></param>
        public static void Apply(this IEnumerable ie, Action<object> action)
        {
            foreach (object e in ie)
            {
                action(e);
            }
        }
    }
}
